package com.zhkj.txg.module.cart.entity

import android.text.TextUtils
import com.chad.library.adapter.base.entity.node.BaseNode
import com.google.gson.annotations.SerializedName
import com.zhkj.lib.http.BaseResponse

data class CartResponse(
    val data: CartEntity? = null
) : BaseResponse()

data class CartEntity(
    val cartList: MutableList<CartShopEntity> = mutableListOf()
) {
    var totalPrice: String = "0"
}

data class CartShopEntity(
    @SerializedName("shop_id")
    val shopId: Int,
    @SerializedName("shop_name")
    val shopName: String = "",
    @SerializedName("shop_img")
    val shopImg: String = "",
    @SerializedName("goods_list")
    val goodsList: MutableList<CartProductEntity> = mutableListOf()
) : BaseNode() {
    override var childNode: MutableList<BaseNode>? = null
}

data class CartProductEntity(
    @SerializedName("cart_id")
    val cartId: Long = 0,
    @SerializedName("goods_id")
    val goodsId: Int,
    @SerializedName("goods_name")
    val goodsName: String = "",
    val image: String = "",
    @SerializedName("share_earn")
    val shareEarn: String = "",
    @SerializedName("is_new")
    val isNew: String = "0",
    @SerializedName("market_price")
    val marketPrice: String = "",
    @SerializedName("goods_price")
    val goodsPrice: String = "0.0",
    @SerializedName("goods_num")
    var goodsNumber: Int,
    @SerializedName("spec_key_name")
    val specName: String = "",
    @SerializedName("is_show")
    val goodsOnSale: String? = null,
    @SerializedName("store_count")
    val storeCount: Int? = null
) : BaseNode() {
    override val childNode: MutableList<BaseNode>? = null
    var selected = false

    // 判断商品是否已上架
    fun isGoodsOnSale() = TextUtils.equals(goodsOnSale, "1")
}